package com.learn.designPatterns.structuralType.Proxy;

import java.net.URL;

/**
 * @classname:
 * @Description:
 * @author: yfpu
 * @Date: 2018-11-01 13:57
 */
public class HighResolutionImage implements Image{

    private URL imageUrl;
    private Long startTime;
    private int height;
    private int width;

    public HighResolutionImage(URL imageUrl) {
        this.imageUrl = imageUrl;
        this.startTime = System.currentTimeMillis();
        this.width = 600;
        this.height = 600;
    }

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public boolean isLoad() {
        //模拟图片加载，延迟 3s 加载
        long end = System.currentTimeMillis();
        return end - startTime > 3000;
    }

    @Override
    public void showImage() {
        System.out.println("Real image: " + imageUrl);
    }
}
